package com.lf.controller;

import com.lf.model.EbUser;
import com.lf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/list")
    public ModelAndView list(@RequestParam(value="page",defaultValue ="1")int page,
                             @RequestParam(value = "pageSize",defaultValue = "3")int pageSize){
        List<EbUser> users=userService.list(page,pageSize);
        int maxPage = userService.getMaxPage(pageSize);
        ModelAndView mv=new ModelAndView();
        //绑定数据

        mv.addObject("useres",users);
        mv.addObject("curPage",page);
        mv.addObject("maxPage",maxPage);
        mv.setViewName("manage/user");
        return mv;
    }
}
